#ifndef _INPUTHANDLER_H
#define _INPUTHANDLER_H

#include "OIS/OISEvents.h"
#include "OIS/OISInputManager.h"
#include "OIS/OISMouse.h"
#include "OIS/OISKeyboard.h"
#include "OIS/OISJoystick.h"
#include "OgreStringConverter.h"
#include "Ogre.h"

//class GameSystemManager;
using namespace Ogre;

class InputHandler : 
	public OIS::MouseListener, 
	public OIS::KeyListener, 
	public OIS::JoyStickListener
{
private:
	OIS::InputManager *mInputManager;
	OIS::Mouse *mMouse;
	OIS::Keyboard *mKeyboard;
	//OIS:: mJoy
	unsigned long m_hWnd;
	
	// MouseListener
	bool mouseMoved(const OIS::MouseEvent &evt);
	bool mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID);
	bool mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID);

	// KeyListener
	bool keyPressed(const OIS::KeyEvent &evt);
	bool keyReleased(const OIS::KeyEvent &evt);

	// JoyStickListener
	bool buttonPressed(const OIS::JoyStickEvent &evt, int index);
	bool buttonReleased(const OIS::JoyStickEvent &evt, int index);
	bool axisMoved(const OIS::JoyStickEvent &evt, int index);
	bool povMoved(const OIS::JoyStickEvent &evt, int index);

	void setWindowExtents(int width, int height) ;

public:
	InputHandler(unsigned long hWnd); 
	~InputHandler();

	void capture();
	void updateMouseMetrics(int width,int height);
	
	bool isRightButtonDown();
	bool isLeftButtonDown();
	bool isMiddleButtonDown();

	const OIS::MouseState getMouseStat();
	
	bool shutDown;

	bool	up;
	bool	down;
	bool	left;
	bool	right;
	bool	forward;
	bool	backward;
	bool	esc;
	
	bool mouseLeftButton;
	bool mouseRightButton;
	bool mouseMiddleButton;

	Radian Pitch,Yaw;
};

#endif